package com.jeesite.modules.dataScreen.web;

import com.jeesite.modules.dataScreen.domain.monitoring.MonitoringDateInfoVo;
import com.jeesite.modules.dataScreen.domain.monitoring.MonitoringDetailVo;
import com.jeesite.modules.dataScreen.domain.monitoring.MonitoringMonthInfoVo;
import com.jeesite.modules.dataScreen.domain.monitoring.MonitoringSimple;
import com.jeesite.modules.dataScreen.service.MonitoringService;
import com.jeesite.modules.dataScreen.web.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/monitoring")
@Api(tags = "首页-舆情相关")
public class MonitoringApi {
    @Resource
    private MonitoringService monitoringService;

    @GetMapping("/list")
    @ApiOperation("列表")
    public Result<List<MonitoringSimple>> getMonitoringSimpleList() {
        List<MonitoringSimple> monitoringSimpleList = monitoringService.getMonitoringSimpleList(null);
        System.out.println("========" +monitoringSimpleList.size());
        return Result.OK(monitoringService.getMonitoringSimpleList(null));
    }

    @GetMapping("/itemCount")
    @ApiOperation("舆情事项计数")
    public Result<Map<String, Object>> getItemCount() {
        return Result.OK(monitoringService.getItemCount());
    }

    @GetMapping("/itemCheck")
    @ApiOperation("舆情事项弹窗列表")
    @ApiImplicitParam(name = "classifyName", required = true, value = "类型名称")
    public Result<List<MonitoringSimple>> getMonitoringSimpleList(@RequestParam String classifyName) {
        return Result.OK(monitoringService.getMonitoringSimpleList(classifyName));
    }

    @GetMapping("/detail")
    @ApiOperation("列表详情")
    public Result<MonitoringDetailVo> detail(@RequestParam String id) {
        return Result.OK(monitoringService.detail(id));
    }


    @GetMapping("/list/publishDate")
    @ApiOperation("按日期查询")
    public Result<MonitoringDateInfoVo> listMonitoringByPublishDate(@ApiParam(value = "查询时间 格式YYYY-MM-dd", required = true)  String publishDate) {
        return Result.OK(monitoringService.listMonitoringByPublishDateCache(publishDate));
    }

    @GetMapping("/getMonthInfo")
    @ApiOperation("近一月舆情信息")
    public Result<MonitoringMonthInfoVo> getMonitoringMonthInfo() {
        return Result.OK(monitoringService.getMonitoringMonthInfoByCache());
    }

}
